package com.hulizuofang.wol.channel.client;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HasHandlers;

public class ChannelMessageEvent extends GwtEvent<ChannelMessageHandler> {
	
	private static final Type<ChannelMessageHandler> TYPE = new Type<ChannelMessageHandler>();
	private final String message;

	ChannelMessageEvent(String data) {
		this.message = data;
	}
	
	public String getMessage() {
		return message;
	}
	
	public static void fire(final HasHandlers source, String data) {
		source.fireEvent(new ChannelMessageEvent(data));
	}

	public static Type<ChannelMessageHandler> getType() {
		return TYPE;
	}
	@Override
	public Type<ChannelMessageHandler> getAssociatedType() {
		return getType();
	}

	@Override
	protected void dispatch(ChannelMessageHandler handler) {
		handler.onMessage(this);
	}
}
